﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using POSSystem.DAL;

namespace POSSystem.BLL
{
    public class View_RealProductQuantity : _View_RealProductQuantity
    {
        public static View_RealProductQuantity GetRealQuantity()
        {
            try
            {
                View_RealProductQuantity realQty = new View_RealProductQuantity();
                realQty.Where.ProductStatusID.Value = (int)ProductDetails.ProductStatus.Purchased;
                realQty.Where.BranchID.Value = Branches.CurrentBranchID;
                realQty.Query.Load();
                return realQty;
            }
            catch (Exception e)
            {
                ErrorLog.WriteToFile("View_RealProductQuantity.cs", "GetRealQuantity", e.StackTrace);
                throw e;
            }
        }

        public static View_RealProductQuantity GetRealQuantityByBrandID(int brandID)
        {
            try
            {
                View_RealProductQuantity realQty = new View_RealProductQuantity();
                realQty.Where.ProductStatusID.Value = (int)ProductDetails.ProductStatus.Purchased;
                realQty.Where.BrandID.Value = brandID;
                realQty.Where.BranchID.Value = Branches.CurrentBranchID;
                realQty.Query.Load();
                return realQty;
            }
            catch (Exception e)
            {
                ErrorLog.WriteToFile("View_RealProductQuantity.cs", "GetRealQuantityByBrandID", e.StackTrace);
                throw e;
            }
        }

        public static View_RealProductQuantity GetRealQuantityByBrandIDStockID(int brandID, int stockID)
        {
            try
            {
                View_RealProductQuantity realQty = new View_RealProductQuantity();
                realQty.Where.ProductStatusID.Value = (int)ProductDetails.ProductStatus.Purchased;
                if(brandID > 0)
                    realQty.Where.BrandID.Value = brandID;
                if (stockID > 0)
                    realQty.Where.StockLocationID.Value = stockID;
                realQty.Where.BranchID.Value = Branches.CurrentBranchID;
                realQty.Query.Load();
                return realQty;
            }
            catch (Exception e)
            {
                ErrorLog.WriteToFile("View_RealProductQuantity.cs", "GetRealQuantityByBrandID", e.StackTrace);
                throw e;
            }
        }
    }
}
